import java.awt.Color;

public class Sprite implements  Comparable<Sprite>, Runnable
{
	//Publics
	String Name = "";
	double x = 0;
	double Xoffset = 0;
	double Yoffset= 0;
	double y = 0;
	int z = 0;
	double rot = 0;
	double vx = 0;
	double vy = 0;
	String picture1;
	String text;
	//vars for geo sprites
	String Type = "";
	int Height = 0;
	int Width = 0;
	Color Col = Color.CYAN; //default colour
	//Privates
	private  long curTime = 0;
	private  long lastTime = 0;
	//Constructor
	public Sprite(String name,String type,String pic,int depth,double X,double Y)
	{
		Name = name;
		Type = type;
		picture1 = pic;		
		x = X;
		y = Y;
		z = depth;
		//System.out.println("Hello, I'm a normal sprite and My name is "+Name);	
	}
	//geosprite overload constructor
	public Sprite(String name,String type,String pic,int depth,double X,double Y,int width,int height,Color col)
	{
		Type = type;
		Name = name;
		picture1 = pic;	
		//it's a geosprite
		Height = height;
		Width = width;
		x = X;
		y = Y;
		z = depth;
		Col = col;
		//System.out.println("Hello, I'm a "+Type+" sprite and My name is "+Name);	
	}
	//this get's overwritten by individual AI classes; hopefully
	public void Process()
	{
	}
	//Time code used for Ai calcs
	public double Timediff()
	{
		lastTime = curTime;
	    curTime = System.nanoTime();
	    if((curTime - lastTime)<40000000)
	    {
	    	return (curTime - lastTime);
	    }else{
	    return (0);}
	}
	// --- functions you don't need to worry about...
	public void Engage()
	{
		if (game.goodpc == true){
		RenderEngine.addsprite(this);
		}else{
		legacyengine.addsprite(this);
		}
	}
	public void Disengage()
	{
		if (game.goodpc == true){
		RenderEngine.removeSprite(this);
		}else{
		legacyengine.removeSprite(this);
		}
	}
	public void setDepth(int newdepth)
	{
		z = newdepth;		
	}
	public void setRotation(int newRot)
	{
		z = newRot;
	}
	public void changeimage(String pic)
	{
		picture1 = pic;	
	}
	public void changeposition(int X, int Y)
	{
	x = X;
	y = Y;
	}
	public void changecolour(Color col)
	{
	Col = col;
	}
	public void changeDimensions(int height, int width)
	{
	Height = height;
	Width = width;
	}
	public boolean isonscreen()
	{
		if (this.x > game.DesiredresX || this.x + this.Width < 0 || this.y > game.DesiredresY || this.y+this.Height < 0){
		 return false;
		}else{
			return true;
		}
	}
	//This is complex Z-buffer stuff, do not mess!
	public int compareTo(Sprite ComparingSprite) {
		  final int BEFORE = -1;
		  final int EQUAL = 0;
		  final int AFTER = 1;
		  if (this.z == ComparingSprite.z ) {return EQUAL;}
		  if (this.z < ComparingSprite.z) {return BEFORE;}
		  if (this.z > ComparingSprite.z) {return AFTER;}
		  return EQUAL;
	}
	@Override
	public void run() {
		// TODO Auto-generated method stub
		
	}
}
